package com.faceye.core.util;



import org.apache.commons.lang3.StringUtils;

import java.text.DecimalFormat;

/**
 * @Description:
 * @Author:haipenge
 * @Date:2020-05-05 12:37
 * @Version:1.0
 **/
public class NumberUtil {
    private static String DEFAULT_PATTERN="#,##0.0#";
    private static DecimalFormat DECIMAL_FORMAT=new DecimalFormat(DEFAULT_PATTERN);

    public static String format(Double number,String pattern){
        DecimalFormat df =null;
        if(StringUtils.isNotEmpty(pattern)){
            df = new DecimalFormat(pattern);
        }else{
            df =DECIMAL_FORMAT;
        }
        if(number!=null) {
            return df.format(number);
        }else{
            return "";
        }

    }
    public static String format(Double number){
        return format(number,null);
    }

}
